package com.objectproject.main.service.subsystem.utility;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.objectproject.main.dao.MyPrimitiveDAOImpl;
import com.objectproject.main.model.primitive.MyPrimitive;
import com.objectproject.main.model.primitive.MyPrimitiveCollection;
import com.objectproject.main.model.primitive.MyPrimitiveDate;
import com.objectproject.main.model.primitive.MyPrimitiveImage;
import com.objectproject.main.model.primitive.MyPrimitiveInteger;
import com.objectproject.main.model.primitive.MyPrimitiveReal;
import com.objectproject.main.model.primitive.MyPrimitiveText;
import com.objectproject.main.model.primitive.MyPrimitiveTime;

@Service
public class PrimitiveUtility {
	
	@Autowired
	MyPrimitiveDAOImpl myPrimitiveDAOImpl;
	
	public long insertMyPrimitiveEasy(MyPrimitive myPrimitive){
		
		if(myPrimitive instanceof MyPrimitiveInteger){
			return myPrimitiveDAOImpl.insertMyPrimitiveInteger((MyPrimitiveInteger)myPrimitive);
		}else if(myPrimitive instanceof MyPrimitiveText){
			return myPrimitiveDAOImpl.insertMyPrimitiveText((MyPrimitiveText)myPrimitive);
		}else if(myPrimitive instanceof MyPrimitiveTime){
			return myPrimitiveDAOImpl.insertMyPrimitiveTime((MyPrimitiveTime)myPrimitive);
		}else if(myPrimitive instanceof MyPrimitiveDate){
			return myPrimitiveDAOImpl.insertMyPrimitiveDate((MyPrimitiveDate)myPrimitive);
		}else if(myPrimitive instanceof MyPrimitiveReal){
			return myPrimitiveDAOImpl.insertMyPrimitiveReal((MyPrimitiveReal)myPrimitive);
		}else if(myPrimitive instanceof MyPrimitiveCollection){
			return myPrimitiveDAOImpl.insertMyPrimitiveCollection((MyPrimitiveCollection)myPrimitive);
		}else if(myPrimitive instanceof MyPrimitiveImage){
			return myPrimitiveDAOImpl.insertMyPrimitiveImage((MyPrimitiveImage)myPrimitive);
		}else{
			//throws exception
		}
		return 0L;
	}
}
